/**
 * @author YinHang
 */
;(function () {
	window.IceTower = function (image, sWidth, sHeight, attackRadius, aggressivity, delay, mode, slowDownValue) {
		window.IceTower.base.call(this, image, sWidth, sHeight, attackRadius, aggressivity, delay, mode, slowDownValue);
		this.slowDownVlaue = slowDownValue || 1;
		this.setFrame(2);
	};
	
	Gamepackage.extend(window.IceTower, Tower);
	var Prototype = window.IceTower.prototype;
	var Physics = Gamepackage.ui.g2d.physics.Physics;
	
	Prototype.sight = function (enemy) {
		if(this.activation)
		{
			var enemyCenterX = enemy.getX() + enemy.getWidth() / 2;
			var enemyCenterY = enemy.getY() + enemy.getHeight() / 2;
			if(Physics.Distance(enemyCenterX, enemyCenterY, this.towerCenterX, this.towerCenterY) <= this.attackRadius)
			{
				enemy.slowDown(this.slowDownVlaue);
				this.rotateAngle = Physics.Angle(this.towerCenterX, this.towerCenterY, enemyCenterX, enemyCenterY);
				return true;
			}
			enemy.slowDown(0);
		}
		return false;
	};
	
	Prototype.clone = function () {
		return new window.IceTower(this.image, this.sWidth, this.sHeight, this.attackRadius, this.aggressivity, null, this.mode, this.slowDownVlaue);
	};
	
})();
